import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:industry_net/base/common/colors_util.dart';
import 'package:industry_net/base/common/img_util.dart';
import 'package:industry_net/base/common/size_fit.dart';
import 'package:industry_net/base/common/text_util.dart';
import 'package:industry_net/base/component/gallery/gallery.dart';
import 'package:industry_net/base/component/gallery/model.dart';
import 'package:industry_net/pages/home/main/controller.dart';
import 'package:industry_net/pages/home/main/models/home_news.dart';

class HomeNewsCell extends StatelessWidget {
  HomeNewsCell({Key? key, required this.mod}) : super(key: key);
  final HomeNewsModel mod;
  final controller = Get.find<HomeController>();
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: gap12, vertical: gap12),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          SizedBox(
            height: 60.w,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text(
                  mod.name,
                  style: pfSCStyle(color: ColorsUtil.title, fontSize: font15),
                ),
                Text(
                  mod.time + ' ' + mod.look_count + '次浏览',
                  style: pfMediumStyle(
                      color: ColorsUtil.content, fontSize: font12),
                )
              ],
            ),
          ),
          Hero(
            tag: mod.id,
            child: InkWell(
              onTap: () {
                var _list = controller.state.news
                    .map((e) => GalleryModel(id: e.id, url: e.avater))
                    .toList();
                var _index = controller.state.news.indexOf(mod);
                gallery(_list, showIndex: _index);
              },
              child: ClipRRect(
                borderRadius: BorderRadius.circular(4.w),
                child: loadImage(url: mod.avater, width: 100.w, height: 60.w),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
